﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GSPatEditor.Pat.Effect.Effects
{
    class DropShellInit : EffectBase
    {
        public override void Generate(StringBuilder sb)
        {
            throw new NotImplementedException();
        }

        public override void Simulate(Simulator.Actor actor)
        {
            Simulator.ActorLabel hitEvent = delegate(Simulator.Actor a)
            {
                a.HitEvent = null;
                a.VX *= 0.7f;
                a.VY *= -0.4f;
            };
            actor.Variables.Add("hitEvent", new Simulator.ActorVariable
            {
                Type = Simulator.ActorVariableType.ActorLabel,
                Value = hitEvent,
            });
            actor.Variables.Add("rotate", new Simulator.ActorVariable
            {
                Type = Simulator.ActorVariableType.Float,
                Value = (float)(-6.0f - (actor.World.Random.Next() % 7)),
            });
        }
    }
    class DropShellUpdate : EffectBase
    {
        public override void Generate(StringBuilder sb)
        {
            throw new NotImplementedException();
        }

        public override void Simulate(Simulator.Actor actor)
        {
            actor.Rotation += (float)(actor.Variables["rotate"].Value);
            actor.VY += 0.5f;
            if (actor.VY > 0)
            {
                actor.HitEvent = (Simulator.ActorLabel)actor.Variables["hitEvent"].Value;
            }
        }
    }
    class RandomScaleXY : EffectBase
    {
        public float Base { get; set; }
        public float Random { get; set; }
        public float RandomScale { get; set; }

        public override void Generate(StringBuilder sb)
        {
            throw new NotImplementedException();
        }

        public override void Simulate(Simulator.Actor actor)
        {
            actor.ScaleX = Base + (actor.World.Random.Next() % Random) * RandomScale;
            actor.ScaleY = Base + (actor.World.Random.Next() % Random) * RandomScale;
        }
    }
    class RandomReverseY : EffectBase
    {
        public override void Generate(StringBuilder sb)
        {
            throw new NotImplementedException();
        }

        public override void Simulate(Simulator.Actor actor)
        {
            if (actor.World.Random.Next() % 10 <= 4)
            {
                actor.ScaleY *= -1;
            }
        }
    }
    class MultiplyScale : EffectBase
    {
        public float Ratio { get; set; }

        public override void Generate(StringBuilder sb)
        {
            throw new NotImplementedException();
        }

        public override void Simulate(Simulator.Actor actor)
        {
            actor.ScaleX *= Ratio;
            actor.ScaleY *= Ratio;
        }
    }
    class ReleaseActor : EffectBase
    {
        public override void Generate(StringBuilder sb)
        {
            throw new NotImplementedException();
        }

        public override void Simulate(Simulator.Actor actor)
        {
            actor.Release();
        }
    }
    class RandomRotation : EffectBase
    {
        public float Base { get; set; }
        public float Random { get; set; }
        public float RandomScale { get; set; }

        public override void Generate(StringBuilder sb)
        {
            throw new NotImplementedException();
        }

        public override void Simulate(Simulator.Actor actor)
        {
            actor.Rotation = Base + (actor.World.Random.Next() % Random) * RandomScale;
        }
    }
    class ShotSpeedRotate : EffectBase
    {
        public float Speed { get; set; }

        public override void Generate(StringBuilder sb)
        {
            throw new NotImplementedException();
        }

        public override void Simulate(Simulator.Actor actor)
        {
            var r = actor.Rotation;
            actor.VX = Speed * (float)Math.Cos(r); //no direction
            actor.VY = Speed * (float)Math.Sin(r);
        }
    }
    class AdjustCollisionRotation : EffectBase
    {
        public override void Generate(StringBuilder sb)
        {
            throw new NotImplementedException();
        }

        public override void Simulate(Simulator.Actor actor)
        {
        }
    }
    class TimeStopCheck : EffectBase
    {
        public override void Generate(StringBuilder sb)
        {
            throw new NotImplementedException();
        }

        public override void Simulate(Simulator.Actor actor)
        {
            //not supported
        }
    }
    class ClearHitEvent : EffectBase
    {
        public override void Generate(StringBuilder sb)
        {
            throw new NotImplementedException();
        }

        public override void Simulate(Simulator.Actor actor)
        {
            actor.HitEvent = null;
        }
    }

}
